<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<script type="text/javascript" src="<%= request.getContextPath()%>/script/questionSet/main.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#backBtn2").click(function () {
            var fromUrl = getParamFromUrl("from");
            if (fromUrl != "") {
                window.location.href = fromUrl;
            } else {
                window.location.href = "list.html";
            }
        });

        QuestionSet.initWuActionButtons("dbtn");
    });
</script>

<!--START: conent -->
<div id="whereUsed" class="content2" style="display:none">
    <div class="insider">
        <div class="corners">
            <div class="corners_top"></div>

            <jsp:include page="briefInfo.jsp"/>

            <ul class="functions1 fun1_2">
                <c:set var="status" value="${questionSet.status.code}"/>
                <c:set var="availability" value="${questionSet.availability.code}"/>

                <c:if test="${OPERATION == 'view'}">
                    <li>
                        <a href="#" onclick="Dialogs.unescapedLink('cancel.html', 'from')">
                            <img src="<%= request.getContextPath()%>/images/btn/functions1/back_to_results.gif"
                                 class="btn"/>
                        </a>
                    </li>

                    <c:if test="${status != 'retired' && availability != 'locked'}">
                        <security:authorize ifAnyGranted="ROLE_PORTAL_USER,ROLE_AUTHOR">
                            <li>
                                <a href="#" onclick="Dialogs.unescapedLink('edit.html?id=${param.id}', 'from')">
                                    <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_edit.gif"
                                         class="btn"/>
                                </a>
                            </li>
                        </security:authorize>
                    </c:if>

                    <c:if test="${status == 'retired' || availability == 'locked'}">
                        <security:authorize ifAnyGranted="ROLE_PORTAL_USER,ROLE_AUTHOR">
                            <li>
                                <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_edit_tint.gif"/>
                            </li>
                        </security:authorize>
                    </c:if>

                    <security:authorize ifAnyGranted="ROLE_PORTAL_USER,ROLE_AUTHOR">
                        <li>
                            <input type="image" id="previewBtn3" class="btn"
                                   src="<%= request.getContextPath()%>/images/btn/functions1/btn_preview.gif"/>
                        </li>
                    </security:authorize>
                </c:if>

                <c:if test="${OPERATION != 'view'}">
                    <li>
                        <input type="image" id="saveBtn3"
                               src="<%= request.getContextPath()%>/images/btn/functions1/btn_save.gif" class="btn"/>
                    </li>
                    <li>
                        <input type="image" id="saveAndExitBtn3" class="btn"
                               src="<%= request.getContextPath()%>/images/btn/functions1/btn_save_exit.gif"/>
                    </li>
                    <li>
                       <jsp:include page="../common/qsCancelButton.jsp" />
                    </li>
                </c:if>
            </ul>
            <div class="corners_bottom"></div>
        </div>

        <div class="error">
            <h3>This Page is used in ${fn:length(questionSet.quesitonSetInNaires)}
                Dialog${fn:length(questionSet.quesitonSetInNaires) > 1 ? 's' : ''}</h3>

            <div class="display_mode">
                <h4>Display mode:</h4>
                <ul>
                    <li id="brief" onclick="briefMode();"><a href="#">Brief</a></li>
                    <li id="full" class="active" onclick="fullMode();"><a href="#">Full</a></li>
                </ul>
            </div>
        </div>

        <!-- Function View and Edit -->
        <ul class="functions2">
            <li class="view">
                <input type="image" name="dbtn" onclick="QuestionSet.wuClickAction('../questionnaire/view')"
                       src="<%=request.getContextPath()%>/images/btn/functions2/btn_view_light.gif" class="btn"/>
            </li>
            <security:authorize ifAnyGranted="ROLE_PORTAL_USER, ROLE_AUTHOR">
                <li>
                    <input type="image" id="editDialogBtn" name="dbtn" onclick="QuestionSet.wuClickAction('../questionnaire/edit')"
                           src="<%=request.getContextPath()%>/images/btn/functions2/btn_edit_light.gif" class="btn"/>
                </li>
            </security:authorize>
        </ul>

        <!-- Header -->
        <table width="100%" cellspacing="0" class="data_thead">
            <thead>
            <tr>
                <th width="15%">Name</th>
                <th width="10%">ID</th>
                <th width="10%">Version</th>
                <th width="15%">Status</th>
                <th width="50%">Title</th>
            </tr>
            </thead>
        </table>
        <!-- Questionnaire List -->
        <div id="dataList" class="data_tbody">
            <c:forEach var="qsin" items="${questionSet.quesitonSetInNaires}">
                <div onclick="QuestionSet.wuItemClick(this, 'id=${qsin.questionnaire.questionnaireId}', 'dbtn');"
                     onmouseover="itemHover(this);" onmouseout="itemMouseOut(this);" class=""
                     pstatus="${qsin.questionnaire.publicationStatus.code}">
                    <table width="100%" cellspacing="0" class="data_tbody_title">
                        <tbody>
                        <tr>
                            <td width="15%" class="id_number">${qsin.questionnaire.name}</td>
                            <td width="10%" class="id_number">${qsin.questionnaire.refId}</td>
                            <td width="10%">${qsin.questionnaire.version}</td>
                            <td width="15%">${qsin.questionnaire.publicationStatus.name}</td>
                            <td width="50%">${qsin.questionnaire.displayTitle}</td>
                        </tr>
                        <tr>
                            <td colspan="5" class="tro"></td>
                        </tr>
                        </tbody>
                    </table>
                    <table width="726" border="0" cellspacing="0" class="tro">
                        <tr>
                            <td width="153">Function: <strong>${qsin.questionnaire.function.code}</strong></td>
                            <td width="269">
                                Last modified:
                                <fmt:formatDate value="${qsin.questionnaire.modifiedOn}" pattern="dd/MM/yyyy"/>
                            </td>
                            <td width="298" class="end">Name: <strong>${qsin.questionnaire.name}</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>Region: <strong>${qsin.questionnaire.region.code}</strong></td>
                            <td><strong>${qsin.questionnaire.description}</strong></td>
                            <td class="end">Vocabulary Name: <strong>${qsin.questionnaire.vocabularyname}</strong>
                        </tr>
                    </table>
                </div>
            </c:forEach>
        </div>
    </div>
</div>
<!--END: conent -->